package com.lmf.springboot.web;

import com.lmf.springboot.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class MyController {

    @Autowired
    private Student student;

    @RequestMapping(value = "/hello")
    public Object dosome(Integer id,String name,Integer age){
        student.setId(id);
        student.setName(name);
        student.setAge(age);
        return student;
    }

    /**
     * restful编程风格
     */
    @RequestMapping(value = "/hello/student/{id}/{name}/{age}")
    public Object dosome2(@PathVariable("id") Integer id,
                          @PathVariable("name") String name,
                          @PathVariable("age") Integer age){
        student.setId(id);
        student.setName(name);
        student.setAge(age);
        return student;
    }
//    @RequestMapping(value = "/hello/student/{id}/{status}/{age}")
    @GetMapping(value = "/hello/student/{id}/{status}/{age}") //通过注解来区分，restful风格中的相同路径问题
    public Object dosome3(@PathVariable("id") Integer id,
                          @PathVariable("status") String name,
                          @PathVariable("age") Integer age){
        student.setId(id);
        student.setName(name);
        student.setAge(age);
        return student;
    }
    @PostMapping(value = "/hello/student/{id}/{status}/{age}") //通过注解来区分，restful风格中的相同路径问题
    public Object dosome4(@PathVariable("id") Integer id,
                          @PathVariable("status") String name,
                          @PathVariable("age") Integer age){
        student.setId(id);
        student.setName(name);
        student.setAge(age);
        return student;
    }
}
